/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package TableView;

import data.Departments;
import data.Sections;
import java.util.ArrayList;
import java.util.List;
import javax.swing.JOptionPane;
import javax.swing.table.AbstractTableModel;
import org.hibernate.Criteria;

/**
 *
 * @author ChiHieu
 */
public class SectionTable extends AbstractTableModel {

	
	private List<Sections> secs;

	public SectionTable() {
		this(new ArrayList<Sections>());
	}

	public SectionTable(List<Sections> secs) {
		this.secs = secs;
	}

	@Override
	public int getRowCount() {
		return secs.size();
	}

	@Override
	public int getColumnCount() {
		return 4;
	}

	@Override
	public Object getValueAt(int rowIndex, int columnIndex) {
		Object value = null;
		Sections sec = secs.get(rowIndex);
		switch (columnIndex) {
			case 0: {
				value = sec.getDepartments().getDeptname();
				break;
			}
			case 1: {
				value = sec.getSectid();
				break;
			}
			case 2: {
				value = sec.getSectname();
				break;
			}
			case 3: {
				value = sec.getSectioninch();
			}
		}
		return value;
	}

	@Override
	public String getColumnName(int column) {
		String value = "";
		switch (column) {
			case 0: {
				value = "DEPNAME";
				break;
			}
			case 1: {
				value = "SECID";
				break;
			}
			case 2: {
				value = "SECNAME";
				break;
			}
			case 3: {
				value = "SECINCH";
				break;
			}
		}
		return value;
	}
}
